//    Copyright (C) Kherty.  All rights reserved.
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Spreadsheet
{
    class CellSmartTag: IOfficeXmlSerializable
    {
        private readonly List<SmartTagProperties> cellSmartTagPr = new List<SmartTagProperties>();

        public List<SmartTagProperties> Properties
        {
            get { return cellSmartTagPr; }
        }


        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (ReadContext c = context.Read("cellSmartTag"))
            {
                Type = c.GetInteger("type");
                Deleted = c.GetOptionalBoolean("deleted", false);
                XmlBased = c.GetOptionalBoolean("xmlBased", false);
                Properties.Clear();
                while (c.ReaderLocalName == "cellSmartTagPr")
                {
                    Properties.Add(c.ReadElement<SmartTagProperties>());
                }

            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("cellSmartTag"))
            {
                c.SetInteger("type", Type);
                c.SetOptionalBoolean("deleted", Deleted, false);
                c.SetOptionalBoolean("xmlBased", XmlBased, false);
                foreach (SmartTagProperties p in Properties)
                    c.WriteElement(p);
            }
        }

        private bool _xmlBased;

        public bool XmlBased
        {
            get { return _xmlBased; }
            set { _xmlBased = value; }
        }
	
        private bool _deleted;

        public bool Deleted
        {
            get { return _deleted; }
            set { _deleted = value; }
        }
	
        private int type;

        public int Type
        {
            get { return type; }
            set { type = value; }
        }
	

        #endregion
    }
}
